// Copyright (c) 2021 Presto Labs Pte. Ltd.
// Author: fengyang

#pragma once

#include <map>
#include <memory>
#include <string>
#include <vector>

#include <simdjson.h>

// internal
#include "coin2/exchange/base/feed/processor.h"
#include "coin2/exchange/base/market/enums.h"
#include "coin2/exchange/di/constant.h"

namespace coin2::exchange::deribit_base::feed_v2 {
namespace impl {
using coin2::exchange::base::executor::TopicRecordPacket;
using namespace coin2::exchange::base::symbology;
class DeribitBaseFeedProcessor : public base::feed::FeedParsingProcessor {
 public:
  explicit DeribitBaseFeedProcessor(
      const std::string& system_name,
      const coin2::exchange::di::ConstantInjection& ci,
      const feed::RawParserConfig& config,
      const MarketExchangeApi& mea)
      : FeedParsingProcessor(
            system_name,
            mea,
            ci,
            config),
        publish_bbo_book_only_(config.publish_bbo_book_only()) {
    if (mea.String() == "Options.Deribit.v2") {
      dynamic_add_product_ = true;
    } else {
      dynamic_add_product_ = false;
    }
  }

  void OnTopicRecord(const base::executor::TopicRecordPacket& packet) override;
 private:
  simdjson::dom::parser parser_;
  const bool publish_bbo_book_only_;
  bool dynamic_add_product_;
};
}  // namespace impl
using impl::DeribitBaseFeedProcessor;
}  // namespace coin2::exchange::deribit_base::feed_v2
